﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class UIManager:MonoBehaviour
{
    public static UIManager instance = null;

    private void Awake()
    {
        instance = this;
    }
    
    #region
    public GameObject MainPanelObject;
    public GameObject ShopPanelObject;
    public GameObject FailPanelObject;
    public GameObject ResumePanelObject;
    public GameObject HammerPanelObject;
    public GameObject RatePanelObject;

    [Space]
    public Transform MainCanvas; 
    public GameObject TutorialPanelObject;
    #endregion

    Hashtable uiBoxTable = new Hashtable();

    private void Start()
    {
        Init();
    }


    private void Init()
    {
        uiBoxTable.Add(UIBoxType.MainPanel, MainPanelObject);
        uiBoxTable.Add(UIBoxType.ShopPanel, ShopPanelObject);

        //dialog
        uiBoxTable.Add(UIBoxType.FailPanel, FailPanelObject);
        uiBoxTable.Add(UIBoxType.ResumePanel, ResumePanelObject);
        uiBoxTable.Add(UIBoxType.HammerPanel, HammerPanelObject);
        uiBoxTable.Add(UIBoxType.RatePanel, RatePanelObject);
    }

    public void ShowBox(UIBoxType type)
    {
        GameObject boxGo = (GameObject)uiBoxTable[type];
        if(boxGo == null)
        {
            return;
        }
        boxGo.GetComponent<UIBoxBase>().ShowBox();
    }

    public void HideBox(UIBoxType type)
    {
        GameObject boxGo = (GameObject)uiBoxTable[type];
        if(boxGo == null)
        {
            return;
        }
        boxGo.GetComponent<UIBoxBase>().HideBox();
    }
    
    public void ShowTutorial()
    {
        Instantiate(TutorialPanelObject, MainCanvas);
    }

}

public enum UIBoxType
{
    MainPanel,
    ShopPanel,
    FailPanel,
    ResumePanel,
    HammerPanel,
    RatePanel
}
